const local = {}

local.set = function (key, value) {
    window.localStorage.setItem(key, JSON.stringify(value));
};

local.get = function (key) {
    var obj = window.localStorage.getItem(key);
    if (obj && obj != 'undefined' && obj != 'null') {
        return JSON.parse(obj);
    }
    return '';
};

local.remove = function (key) {
    if (key) {
        window.localStorage.removeItem(key);
    } else {
        for (var i in arguments) {
            window.localStorage.removeItem(arguments[i]);
        }
    }
};

local.clear = function () {
    window.localStorage.clear();
};

//  * seek 检查本地是否有值

local.seek = function (name) {
    if (!name) return;
    return window.localStorage.hasOwnProperty(name)
}

export default local
